<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
 
<script type="text/javascript">


	$(function(){
		
		//绑定回车事件
		$(':input').bind('keyup', function(event){
		   if (event.keyCode=="13"){
		   		$("#base_info_form").submit();
		   }
		});
		
		yearMonthDay($("#base_info_birthday"),'${detail.birthday}');
		initProCityDis('now_province','now_city','now_district','address');
		initProCityDis('birth_province','birth_city','birth_district','birth_address');
		var bList = birthdaySplit('${detail.birthday}');
		$("#year").val(bList[0]);
		$("#month").val(bList[1]);
		$("#day").val(bList[2]);
		
		
		$("#now_province").val("${detail.provice}");
		changeProvince("now_province","now_city");
		$("#now_city").val("${detail.city}");
		changeCity("now_city","now_district");
		$("#now_district").val("${detail.district}");
		
		$("#birth_province").val("${detail.birthProvice}");
		changeProvince("birth_province","birth_city");
		$("#birth_city").val("${detail.birthCity}");
		changeCity("birth_city","birth_district");
		$("#birth_district").val("${detail.birthDistrict}");
		
		$.metadata.setType("attr","validate");
		$("#base_info_form").validate({
			submitHandler: function() {
				var year = $("#year").val();
				var month = $("#month").val();
				var day = $("#day").val();
				var now_province = $("#now_province").val();
				var now_city = $("#now_city").val();
				var now_district = $("#now_district").val();
				var address = $("#address").val();
				var birth_province = $("#birth_province").val();
				var birth_city = $("#birth_city").val();
				var birth_district = $("#birth_district").val();
				var birth_address = $("#birth_address").val();
				var role = $(":radio[name='role'][checked]").val(); 
				$("#delButton").attr("onclick","");
				$.post("saveBaseInfo.htm?memberId="+$("#memberId").html(),{
							'birthday':year+'-'+month+'-'+day,
							'provice':now_province,
							'city':now_city,
							'district':now_district,
							'address':address,
							'birthProvice':birth_province,
							'birthCity':birth_city,
							'birthDistrict':birth_district,
							'birthAddress':birth_address,
							'role':role,
							'username':$("#username").val()
							},function(data){
								if(data=='success'){
									refreshParentsAvatar();
									$("#member_info_detail").load("baseInfo.htm?memberId="+$("#memberId").html(),function(){
										showSuccess();
									});
									$("#gxzl1").attr("class", "current");
								}
							});
			}
		});
	});
	
	
	function xiuGaiName(){
		$("#test").remove();
		$("#username").show();
	}

</script>

<div class="success" id="base_info_tip_success" style="display: none; margin-left: 32px;"><img alt="修改成功" src="<%=basePath %>images/home_images/ico29.png">基本资料填写成功</div>
	<form action="" id="base_info_form">
		<div class="h_dataInfo">
                    <table width="597">
                      <tr>
                        <td width="61" class="data_text"><c:if test="${member.isHost==true }">户主</c:if><c:if test="${member.isHost==false }">成员</c:if>姓名：</td>
                        <td width="524">
                        <input type="text" style="display: none;" id="username" value="<c:out value="${member.username}" />"
  							 validate="{required:true,chinese:24,minlength:2,maxlength:20,
  							 messages:{required:'姓名不能为空',chinese:'姓名为2个以上汉字',minlength:'姓名为2个以上汉字',maxlength:'长度不能超过20个字符'}}" />
                        <span id="test"><c:out value="${member.username}" /><strong><a href="javascript:void(0)" onclick="xiuGaiName()">【可修改】</a></strong></span></td>
                      </tr>
                      <tr>
                        <td class="data_text">生日：</td>
                        <td id="base_info_birthday">
						<select id="year" name="year"></select>
						<select id="month" name="month"></select>
						<select id="day" name="day"></select>
					</td>
                      </tr>
                     <tr>
                        <td class="data_text">现居地：</td>
                        <td class="data_input">
                             <select id="now_province" ></select>
							<select id="now_city"></select>
							<select id="now_district"></select>
                            </td>   
                      </tr>
                      <tr>
                      <td class="data_text">详细地址：</td>
                      <td class="data_input"><input type="text" id="address" name="address" validate="{maxlength:20,messages:{maxlength:'长度不能超过20个字符'}}" value="${detail.address}"/></td>
                      </tr>
                      <tr>
                        <td class="data_text">家乡：</td>
                        <td class="data_input">                           
                            <select id="birth_province"></select>
							<select id="birth_city"></select>
							<select id="birth_district"></select>
                            </td>
                      </tr>
                       <tr>
                      <td class="data_text">详细地址：</td>
                      <td class="data_input"><input type="text" id="birth_address" name="birth_address"  validate="{maxlength:20,messages:{maxlength:'长度不能超过20个字符'}}" value="${detail.birthAddress}"/></td>
                      </tr>
                      <tr>
                        <td class="data_text">角色：</td>
                        <td>
                        <input name="role" type="radio" value="${member.role }" checked
						 validate="{required:true,messages:{required:'请选择角色'}}"/>${member.roleLabel }
						 <%--
						<input name="role" type="radio"  value="02"
						<c:if test="${member.role=='02'}">checked</c:if>
						 validate="{required:true,messages:{required:'请选择角色'}}"/>妈妈
						&nbsp;&nbsp;<label for="role" generated="true" class="error" style="display: none;"></label>
						 --%>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <table>
                      <tr>
                        <td width="135"></td>
                        <td width="524"> 
                        <div class="h_button w75 mt15"><strong id="delButton" onclick="javascript:$('#base_info_form').submit();">保存设置</strong></div>
                	  </td>
                      </tr>
                    </table>
	</form>
